/**
 * 
 */
package com.orange.notificationsummary;

import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

/**
 * @author ying.zhao
 * 
 */
public class EventListAdapter extends BaseAdapter {

	private List<String>	mTextArray;
	private Context			mContext;
	private List<?>			mParam;

	EventListAdapter(Context context, List<String> textArray, List<?> param) {
		super();

		mContext = context;
		mTextArray = textArray;
		mParam = param;
	}

	@Override
	public int getCount() {
		return mTextArray.size();
	}

	@Override
	public Object getItem(int arg0) {
		return arg0;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater layoutInflater = (LayoutInflater) mContext
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View itemView = layoutInflater.inflate(R.layout.setting_event_list,
				parent, false);

		TextView text = (TextView) itemView.findViewById(R.id.event_text);
		text.setText(mTextArray.get(position));

		CheckBox bn = (CheckBox) itemView.findViewById(R.id.event_check);
		if (mParam != null && !mParam.isEmpty()) {
			bn.setChecked((Boolean) mParam.get(position));
		}
		if (position > 2) {
			itemView.setEnabled(false);
			itemView.setClickable(false);
			text.setEnabled(false);
			bn.setEnabled(false);
			bn.setChecked(false);
		} else {
			bn.setEnabled(true);
			text.setTextColor(Color.WHITE);
		}
		return itemView;
	}

}
